﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data.SQLite;

namespace ClassLibrarySQLite
{
    public sealed class ClassDBBusinesses :  ClassSQLiteHelper
    {
        public static SQLiteConnection CreatDB(string ip, string connectionKeyStrings)
        {
            return CreatDbWithConneton(ip, connectionKeyStrings);
        }

        public static SQLiteConnection JustConnectDB(string ip, string connectionKeyStrings)
        {
            return ConnectDB(ip, connectionKeyStrings);
        }

 /// <summary>
 /// 
 /// </summary>
 /// <param name="sqconnection"></param>
        public static void CreatUnifyInfosWatchBoardTable(ref SQLiteConnection sqconnection)
        {         
            string sql = "create table UnifyInfosBoardTable1 (id integer primary key autoincrement,infostring text)";
            CreatTable(ref sqconnection, sql);
        }
        public static int InsertUnifyInfosBoardTable(ref SQLiteConnection sqconnection,string infostr)
        {
            string sql = string.Format("insert into UnifyInfosBoardTable1 (infostring) values('{0}')",infostr);
            return InsertData(ref sqconnection, sql);
        }
        private static int UpdataUnifyInfosBoardTable(ref SQLiteConnection sqconnection, string infostr)
        {
            string sql = string.Format("update UnifyInfosBoardTable1 set infostring='{0}' where id=1", infostr);
            return InsertData(ref sqconnection, sql);
        }

        public static string ReadUnifyInfosBoardTableFirst(ref SQLiteConnection sqconnection)
        {
            string sql = string.Format("select infostring from UnifyInfosBoardTable1 where id=1");
            string  res= ReadData(ref sqconnection, sql);
            return res;
        }

        public static int CountUnifyInfosBoardTableDataNumber(ref SQLiteConnection sqconnection)
        {
            string sql = string.Format("select count(*) from UnifyInfosBoardTable1");
            int res = CountTableAllDataNumber(ref sqconnection, sql);
            return res;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="sqconnection"></param>
        public static void CreatWorkStepsJampEndAllDataTable(ref SQLiteConnection sqconnection)
        {           
            string sql = "create table WorkStepsJampEndAllDataTable (id integer primary key autoincrement,workstepname text,endallinfostring text)";
            CreatTable(ref sqconnection, sql);
        }


        /// <summary>
        /// 
        /// </summary>
        /// <param name="sqconnection"></param>
        public static void CreatRealDataTable(ref SQLiteConnection sqconnection)
        {
            string sql = "create table RealDataTable (id integer primary key autoincrement,realdatastring text)";
            CreatTable(ref sqconnection, sql);
        }
    }
}
